//src/user/user.controller.ts
import { Controller, Get, UseGuards, Req } from '@nestjs/common';
import { AuthGuard } from './auth/auth.guard'; // 确保路径正确
import { AuthService } from './auth/auth.service'; // 假设你有一个UserService来处理用户数据

@Controller('user')
export class UserController {
  constructor(private readonly userService: AuthService) {}
  @UseGuards(AuthGuard)
  @Get('profile')
  async getUserInfo(@Req() req): Promise<any> {
    const user = await this.userService.findUserById(req.user.id); 
    console.log('User from database:', user); // 打印数据库中的用户信息
    return user;
}
}